from django.shortcuts import render
from app01.models import Novel


# Create your views here.


def novel(request):
    coo = request.session.get('info', "")
    if request.method == 'GET':
        queryset = Novel.objects.all().order_by("-likes")[:15]
        hot_queryset = Novel.objects.all().order_by("-likes")[:10]
        return render(request, "light_novel/light_novel_main.html", {"queryset": queryset, "hot_queryset": hot_queryset, "order": (i for i in range(0, 10)), "coo": coo})


def novel_read(request, id):
    coo = request.session.get('info', "")
    if request.method == 'GET':
        read_novel = Novel.objects.filter(id=id).first()
        return render(request, "light_novel/light_novel.html", {"read_novel": read_novel, "coo": coo})


def novel_show(request, type):
    coo = request.session.get('info', "")
    if request.method == 'GET':
        show_novel = Novel.objects.all()
        return render(request, "light_novel/light_novel_show.html", {"show_novel": show_novel, "coo": coo})